package com.intelligentcar.springboot.controller;

import com.intelligentcar.springboot.bean.Carrepair;
import com.intelligentcar.springboot.bean.Manager;
import com.intelligentcar.springboot.service.CarrepairServer;
import org.apache.ibatis.session.RowBounds;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

@Controller
public class CarrepairController {
    @Autowired
    private CarrepairServer carrepairServerImpl;

    //查看车辆维修表的所有数据
    @RequestMapping("/carrepair")
    @ResponseBody
    public Map carrepair(@RequestBody Carrepair carrepair) {
        Map map = new HashMap();
        map.put("total", carrepairServerImpl.carrepairnum());
        map.put("list", carrepairServerImpl.carrepair(new RowBounds((carrepair.getPage() - 1) * carrepair.getSize(), carrepair.getSize())));
        return map;
    }

    //在维修车辆表中安排维修人员
    @RequestMapping("/arrangerepair")
    @ResponseBody
    public Map arrangerepair(HttpServletRequest req, @RequestBody Carrepair carrepair) {
        Map map = new HashMap();
        map.put("code", carrepairServerImpl.arrangerepair( req,carrepair));
        return map;
    }

    //在维修车辆表中删除数据
    @RequestMapping("/deletecarrepair")
    @ResponseBody
    public Map deletecarrepair(HttpServletRequest req, @RequestBody Carrepair carrepair) {
        Map map = new HashMap();
        map.put("code", carrepairServerImpl.deletecarrepair(req,carrepair));
        return map;
    }
}
